import { log } from "console";

class Test {
    static x = 1;
    #a = 1; // private property
    constructor({ name }) {
        this.n = 0;
        this._name = name;
        this.#a = 1;
        this['age'] = 12;
        this.list = ['a', 'b', 'c', 'd'];
        this.x = 2;
    }

    testClosure() {
        let index = 0;
        let self = this
        return {
            next() {
                log(this);
                return self.list[index++];
            }
        };
    }

    test() {
        return { a: () => { log(this) } };
    }

    static testStatic() {
        log(this.x);
    }

    testListParams(...p) {
        log(p.length);
    }

    toString() {
        return `name is ${this._name}`;
    }
}

var test = new Test({ name: 'tom' });
//log(JSON.stringify(test))
//log(test)

log(test.test().a())






